import type { UserRecord } from '@/DatabaseType/User';
import { Tag } from 'antd';
import { useModel } from '@umijs/max';

export default function useRoleList() {
  const { initialState } = useModel('@@initialState');
  const currentUser = initialState?.currentUser as UserRecord;

  const roleList = currentUser?.roles || [];

  return roleList.map((role) => {
    return (
      <Tag color="blue" key={role.id}>
        {role.znName}
      </Tag>
    );
  });
}
